package com.shy.transaction.service.impl;

import com.shy.transaction.dao.IUserDao;
import com.shy.transaction.entity.User;
import com.shy.transaction.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService implements IUserService {
    @Resource
    private IUserDao userDao;
    @Override
    @Transactional
    public Integer insert() {
        Integer result = userDao.insert("黄小小小大");
        throw new RuntimeException("测试回滚");
//        return result;
    }

    @Override
    public Integer update() {
        return userDao.update(2, "黄小小很小");
    }

    @Override
    public User queryById() {
        return userDao.queryById(2);
    }

    @Override
    public Integer delete() {
        return userDao.delete(3);
    }
}
